<template>
    <div class="order-report">
        <div class="report-table-top-title">
            开票申请列表
        </div>
        <div class="report-table-form1">
            <div class="report-table-form1-line">
                <div class="report-table-form1-item word samll" style="width: 50px">代理商:</div>
                <div class="report-table-form1-item" style="width: 180px">
                    <el-select v-model="value1" filterable placeholder="请选择" size="small">
                        <el-option
                            v-for="item in options1"
                            :key="item.id"
                            :label="item.userName"
                            :value="item.id"
                        ></el-option>
                    </el-select>
                </div>
                <div class="report-table-form1-item word samll" style="width: 50px">订单号:</div>
                <div class="report-table-form1-item" style="width: 180px">
                    <el-input
                        v-model="searchNo"
                        placeholder
                        size="small"
                        suffix-icon="el-icon-search"
                    ></el-input>
                </div>
                <div class="report-table-form1-item word samll" style="width: 70px">申请日期:</div>
                <div class="report-table-form1-item" style="width: 200px">
                    <el-date-picker
                        size="small"
                        v-model="timeStart"
                        type="date"
                        value-format="yyyy-MM-dd 00:00:00"
                        placeholder="选择日期"
                    ></el-date-picker>
                </div>
                <div class="report-table-form1-item word samll" style="width: 12px">至</div>
                <div class="report-table-form1-item" style="width: 200px">
                    <el-date-picker
                        size="small"
                        v-model="timeEnd"
                        type="date"
                        value-format="yyyy-MM-dd 23:59:59"
                        placeholder="选择日期"
                    ></el-date-picker>
                </div>
                <div class="report-table-form1-item word samll" style="width: 40px"></div>
                <el-button type="primary" size="small" @click="search">查询</el-button>
            </div>
        </div>
        <div class="page-padding-gray-small"></div>
        <div class="report-table-wrapper">
            <el-table
                :header-cell-style="headerCellStyle"
                size="small"
                :data="showList"
                border
                style="width: 100%"
            >
                <el-table-column prop="orderNo" label="订单号" width="80"></el-table-column>
                <el-table-column prop="orderContent" label="购买内容"></el-table-column>
                <el-table-column prop="orderQuantity" label="购买数量">
				</el-table-column>
                <el-table-column prop="orderPrice" label="单价"></el-table-column>
                <el-table-column prop="totalMoney" label="支付金额"></el-table-column>
                <el-table-column prop="orderDateTime" label="下单时间">
                    <template slot-scope="props">
                        <div>{{$FS(props.row.orderDateTime)}}</div>
                    </template>
				</el-table-column>
                <el-table-column prop="invoiceRemarks" label="开票备注"></el-table-column>
                <el-table-column prop="invoiceApplyDateTime" label="申请开票时间">
                    <template slot-scope="props">
                        <div>{{$FS(props.row.invoiceApplyDateTime)}}</div>
                    </template>
				</el-table-column>
                <el-table-column prop="invoiceAddress" label="收货地址"></el-table-column>
                <el-table-column prop="invoicePhone" label="收货人电话"></el-table-column>
                <el-table-column prop="invoiceName" label="收货人名称"></el-table-column>
                <el-table-column prop="isInvoice" label="处理状态"></el-table-column>
                <el-table-column prop="invoiceHandleTime" label="处理时间">
                    <template slot-scope="props">
                        <div>{{$FS(props.row.invoiceHandleTime)}}</div>
                    </template>
				</el-table-column>
                <el-table-column label="操作" width="100">
                    <template slot-scope="scope">
                        <el-button v-show="scope.row.isInvoice === 0"
                            size="mini"
                            type="primary"
                            @click="toHandle(scope.$index, scope.row)"
                        >处理</el-button>
                        <el-button  v-show="scope.row.isInvoice === 1"
                            size="mini"
                            type="primary"
                            @click="toNotHandle(scope.$index, scope.row)"
                        >取消处理</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>

        <div class="report-table-block">
            <div class="report-table-block-in">
                <el-pagination
                    background
                    :current-page.sync="position"
                    @current-change="handleCurrentChange"
                    :page-size="10"
                    layout="prev, pager, next, total"
                    :total="totalNum"
                ></el-pagination>
            </div>
        </div>
        <div class="page-padding"></div>
    </div>
</template>

<script type="text/ecmascript-6">
export default {
    data: function () {
        return {
            totalNum: 0,
            position: 1,
            timeStart: '',
            timeEnd: '',
            options1: [
                {
                    userName: '全部',
                    id: ''
                }
            ],
            value1: '',
            searchNo: '',
            showList: [
                {
                    orderNo: 1,
                    orderContent: '卡台B段',
                    orderQuantity: 1,
                    orderPrice: '100.00',
                    totalMoney: '100.00',
                    orderDateTime: '1589028606000',
                    invoiceRemarks: '',
                    invoiceApplyDateTime: '1589028606000',
                    invoiceAddress: '',
                    invoicePhone: '123123123',
                    invoiceName: '测试',
                    isInvoice: 0,
                    invoiceHandleTime: '1589028606000'
                }
            ]
        }
    },
    mounted () {
    },
    created () {
        this.getAllAgent()
        // this.getPage()
    },
    watch: {
        value1 () {
            this.position = 1
            // this.getPage()
        },
        position () {
            // this.getPage()
        }
    },
    components: {
    },
    props: {
        underLine: null
    },
    computed: {
    },
    methods: {
        toHandle (index, row) {
            this.$http.post(this.$store.state.IP + '/skinPackage/saveOrEdit', {
                orderNo: this.serviceCodeEdit
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('处理开票申请信息成功')
                    console.log(response.data)
                    this.getPage()
                    this.$message({
                        showClose: true,
                        message: '编辑成功',
                        type: 'success'
                    })
                }
                if (response.ret !== '0') {
                    console.log('处理开票申请信息失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },
        search () {
            this.position = 1
            if (this.timeStart > this.timeEnd) {
                this.$message({
                    message: '开始时间不能大于结束时间',
                    type: 'warning'
                })
                return
            }
            this.getPage()
        },
        getAllAgent () {
            this.$http.post(this.$store.state.IP + '/system/company/getAllAgent', {
                data: {
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('调用获取所有代理商成功')
                    console.log(response.data)
                    response.data.forEach(item => {
                        this.options1.push(item)
                    })
                }
                if (response.ret !== '0') {
                    console.log('调用获取所有代理商失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },

        // 换页方法
        handleCurrentChange (val) {
            this.position = val
        },
        getPage () {
            this.$http.post(this.$store.state.IP + '/system/stock/getStockStatistics', {
                data: {
                    agentId: this.value1,
                    page: this.position - 1, // 页数
                    limit: 10 // 一页显示数量
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('调用增值服务待办列表成功')
                    console.log(response.data)
                    this.showList = response.data.list
                    this.totalNum = response.data.total
                }
                if (response.ret !== '0') {
                    console.log('调用增值服务待办列表失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        }
    }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
.order-report
    width: 100%
    background #fff
    min-height calc(100vh - 65px)

    .report-table-top-title
        width: 100%
        height: 64px
        line-height: 64px
        color: #000
        font-size: 18px
        background #f1f0f5

     .report-table-form1
        width: 100%
        min-height: 40px
        padding: 16px 0 0 22px
        box-sizing border-box
        background #fff
        overflow hidden

        .report-table-form1-line
            min-height: 32px
            margin-bottom: 16px

            .report-table-form1-item
                display: inline-block
                vertical-align: top
                height: 32px
                margin-right: 15px
                line-height: 32px

                &.word
                    margin-right: 0

                &.samll
                    font-size: 15px
                    text-align left

                &.big
                    margin-right: 100px

    .report-table-block
        width: 100%
        padding-top: 22px
        height 50px
        background #fff
        box-sizing border-box

        .report-table-block-in
            float: right
            padding-right 17px

    .page-padding-gray-small
        width: 100%
        height: 22px
        background #f1f0f5
    .page-padding
        width: 100%
        height: 20px
        background #fff


    .report-table-total
        width: 100%
        font-size: 16px
        color #409EFF
        padding: 22px
        margin-top 22px
        box-sizing border-box
        background #fff
</style>
